<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Redis终结 | flybird&#39;s blog</title>
    <meta name="generator" content="VuePress 1.8.0">
    <link rel="icon" href="https://infinitypro-img.infinitynewtab.com/custom-icon/8001de1jd3n68lbfnxxt564xvb0vl5.png?imageMogr2/thumbnail/240x/format/webp/blur/1x0/quality/100|imageslim">
    <script language="javascript" type="text/javascript" src="https://cdn.staticfile.org/jquery/1.7.2/jquery.min.js"></script>
    <script language="javascript" type="text/javascript" src="/js/MouseClickEffect.js"></script>
    <meta name="description" content="Stay hungry, Stay foolish">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/assets/css/0.styles.324c77a5.css" as="style"><link rel="preload" href="/assets/js/app.55c4f7c3.js" as="script"><link rel="preload" href="/assets/js/5.86109dd2.js" as="script"><link rel="preload" href="/assets/js/1.74974061.js" as="script"><link rel="preload" href="/assets/js/2.ab8aa845.js" as="script"><link rel="preload" href="/assets/js/85.55a516f8.js" as="script"><link rel="preload" href="/assets/js/18.cfe435f1.js" as="script"><link rel="prefetch" href="/assets/js/10.1f3187f9.js"><link rel="prefetch" href="/assets/js/11.67fe3d1f.js"><link rel="prefetch" href="/assets/js/12.0052f325.js"><link rel="prefetch" href="/assets/js/13.bad60b36.js"><link rel="prefetch" href="/assets/js/14.6a893378.js"><link rel="prefetch" href="/assets/js/15.899648d3.js"><link rel="prefetch" href="/assets/js/16.0575f88b.js"><link rel="prefetch" href="/assets/js/17.86f820d7.js"><link rel="prefetch" href="/assets/js/19.1d1c7b67.js"><link rel="prefetch" href="/assets/js/20.218819f6.js"><link rel="prefetch" href="/assets/js/21.223949af.js"><link rel="prefetch" href="/assets/js/22.eb6ea80c.js"><link rel="prefetch" href="/assets/js/23.cf07ba0c.js"><link rel="prefetch" href="/assets/js/24.eeb9d511.js"><link rel="prefetch" href="/assets/js/25.4be64ae7.js"><link rel="prefetch" href="/assets/js/26.6aea0ced.js"><link rel="prefetch" href="/assets/js/27.7540f161.js"><link rel="prefetch" href="/assets/js/28.d88a26e6.js"><link rel="prefetch" href="/assets/js/29.7edc404c.js"><link rel="prefetch" href="/assets/js/30.b3c16bef.js"><link rel="prefetch" href="/assets/js/31.63392d40.js"><link rel="prefetch" href="/assets/js/32.b90695c8.js"><link rel="prefetch" href="/assets/js/33.669186a5.js"><link rel="prefetch" href="/assets/js/34.57a9b7fc.js"><link rel="prefetch" href="/assets/js/35.81d5b8b3.js"><link rel="prefetch" href="/assets/js/36.466fde53.js"><link rel="prefetch" href="/assets/js/37.ff7b9321.js"><link rel="prefetch" href="/assets/js/38.132de18a.js"><link rel="prefetch" href="/assets/js/39.80a51963.js"><link rel="prefetch" href="/assets/js/40.e7d6c67d.js"><link rel="prefetch" href="/assets/js/41.d195ea4b.js"><link rel="prefetch" href="/assets/js/42.dbe1a8f1.js"><link rel="prefetch" href="/assets/js/43.2ea02aec.js"><link rel="prefetch" href="/assets/js/44.294015bc.js"><link rel="prefetch" href="/assets/js/45.3cf9c326.js"><link rel="prefetch" href="/assets/js/46.8cc95701.js"><link rel="prefetch" href="/assets/js/47.ddf6cc44.js"><link rel="prefetch" href="/assets/js/48.ba718ca6.js"><link rel="prefetch" href="/assets/js/49.feee5279.js"><link rel="prefetch" href="/assets/js/50.6f2d0d0d.js"><link rel="prefetch" href="/assets/js/51.ebe1eb07.js"><link rel="prefetch" href="/assets/js/52.3e47f7ae.js"><link rel="prefetch" href="/assets/js/53.861fb703.js"><link rel="prefetch" href="/assets/js/54.f7d3a937.js"><link rel="prefetch" href="/assets/js/55.d90baa98.js"><link rel="prefetch" href="/assets/js/56.ba7f3256.js"><link rel="prefetch" href="/assets/js/57.90441d7f.js"><link rel="prefetch" href="/assets/js/58.a0d58abc.js"><link rel="prefetch" href="/assets/js/59.7f649313.js"><link rel="prefetch" href="/assets/js/6.00dfc51e.js"><link rel="prefetch" href="/assets/js/60.60dd83d2.js"><link rel="prefetch" href="/assets/js/61.b84cd1ef.js"><link rel="prefetch" href="/assets/js/62.8ed6541f.js"><link rel="prefetch" href="/assets/js/63.84bfbbbf.js"><link rel="prefetch" href="/assets/js/64.01c483db.js"><link rel="prefetch" href="/assets/js/65.278ce63e.js"><link rel="prefetch" href="/assets/js/66.cb493053.js"><link rel="prefetch" href="/assets/js/67.8c2201b6.js"><link rel="prefetch" href="/assets/js/68.46467c87.js"><link rel="prefetch" href="/assets/js/69.ee34297d.js"><link rel="prefetch" href="/assets/js/7.aaee1baa.js"><link rel="prefetch" href="/assets/js/70.3a016bcf.js"><link rel="prefetch" href="/assets/js/71.1cb787d0.js"><link rel="prefetch" href="/assets/js/72.2ee0677e.js"><link rel="prefetch" href="/assets/js/73.3e1e1729.js"><link rel="prefetch" href="/assets/js/74.947d7cd3.js"><link rel="prefetch" href="/assets/js/75.2e5c7344.js"><link rel="prefetch" href="/assets/js/76.6c098cc2.js"><link rel="prefetch" href="/assets/js/77.03fd3a89.js"><link rel="prefetch" href="/assets/js/78.38d2d963.js"><link rel="prefetch" href="/assets/js/79.ea508df9.js"><link rel="prefetch" href="/assets/js/8.35d0b089.js"><link rel="prefetch" href="/assets/js/80.b2b1dda3.js"><link rel="prefetch" href="/assets/js/81.d7db5a4d.js"><link rel="prefetch" href="/assets/js/82.1c148069.js"><link rel="prefetch" href="/assets/js/83.51e2c0d0.js"><link rel="prefetch" href="/assets/js/84.6118b266.js"><link rel="prefetch" href="/assets/js/86.3b73f7a9.js"><link rel="prefetch" href="/assets/js/87.123149cb.js"><link rel="prefetch" href="/assets/js/88.f87dde9d.js"><link rel="prefetch" href="/assets/js/89.06c3b9a1.js"><link rel="prefetch" href="/assets/js/9.58e6c220.js"><link rel="prefetch" href="/assets/js/vendors~flowchart.080f3458.js">
    <link rel="stylesheet" href="/assets/css/0.styles.324c77a5.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div><div class="theme-container" data-v-0b87bb44><div data-v-0b87bb44><div id="loader-wrapper" class="loading-wrapper" data-v-1c4f0192 data-v-0b87bb44 data-v-0b87bb44><div class="loader-main" data-v-1c4f0192><div data-v-1c4f0192></div><div data-v-1c4f0192></div><div data-v-1c4f0192></div><div data-v-1c4f0192></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-73c95a87 data-v-0b87bb44 data-v-0b87bb44><h3 class="title" style="display:none;" data-v-73c95a87 data-v-73c95a87>flybird's blog</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-73c95a87 data-v-73c95a87><input type="password" value="" data-v-73c95a87> <span data-v-73c95a87>Konck! Knock!</span> <button data-v-73c95a87>OK</button></label> <div class="footer" style="display:none;" data-v-73c95a87 data-v-73c95a87><span data-v-73c95a87><i class="iconfont reco-theme" data-v-73c95a87></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-73c95a87>vuePress-theme-reco</a></span> <span data-v-73c95a87><i class="iconfont reco-copyright" data-v-73c95a87></i> <a data-v-73c95a87><span data-v-73c95a87>flybird</span>
            
          <span data-v-73c95a87>2020 - </span>
          2021
        </a></span></div></div> <div class="hide" data-v-0b87bb44><header class="navbar" data-v-0b87bb44><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">flybird's blog</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/index.html" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/大数据/" class="nav-link"><i class="iconfont undefined"></i>
  大数据
</a></li><li class="dropdown-item"><!----> <a href="/categories/后端/" class="nav-link"><i class="iconfont undefined"></i>
  后端
</a></li><li class="dropdown-item"><!----> <a href="/categories/中间件/" class="nav-link"><i class="iconfont undefined"></i>
  中间件
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><a href="/about/" class="nav-link"><i class="iconfont reco-message"></i>
  关于我
</a></div> <a href="https://github.com/f1ybird" target="_blank" rel="noopener noreferrer" class="repo-link"><i class="iconfont reco-github"></i>
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask" data-v-0b87bb44></div> <aside class="sidebar" data-v-0b87bb44><div class="personal-info-wrapper" data-v-7e653f02><img src="/vuepress/my-head.png" alt="author-avatar" class="personal-img" data-v-7e653f02> <h3 class="name" data-v-7e653f02>
    flybird
  </h3> <div class="num" data-v-7e653f02><div data-v-7e653f02><h3 data-v-7e653f02>63</h3> <h6 data-v-7e653f02>文章</h6></div> <div data-v-7e653f02><h3 data-v-7e653f02>26</h3> <h6 data-v-7e653f02>标签</h6></div></div> <hr data-v-7e653f02></div> <nav class="nav-links"><div class="nav-item"><a href="/index.html" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/大数据/" class="nav-link"><i class="iconfont undefined"></i>
  大数据
</a></li><li class="dropdown-item"><!----> <a href="/categories/后端/" class="nav-link"><i class="iconfont undefined"></i>
  后端
</a></li><li class="dropdown-item"><!----> <a href="/categories/中间件/" class="nav-link"><i class="iconfont undefined"></i>
  中间件
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><a href="/about/" class="nav-link"><i class="iconfont reco-message"></i>
  关于我
</a></div> <a href="https://github.com/f1ybird" target="_blank" rel="noopener noreferrer" class="repo-link"><i class="iconfont reco-github"></i>
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><a href="/views/" aria-current="page" class="sidebar-link">概览</a></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>大数据</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>中间件</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>后端</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/views/java/ArrayList.html" class="sidebar-link">ArrayList底层实现和原理</a></li><li><a href="/views/java/HashMap.html" class="sidebar-link">HashMap底层实现和原理</a></li><li><a href="/views/java/docker.html" class="sidebar-link">Docker的基本了解和使用</a></li><li><a href="/views/java/itext.html" class="sidebar-link">itext:PDF导出</a></li><li><a href="/views/java/poi.html" class="sidebar-link">poi多线程多sheet导出Excel,csv</a></li><li><a href="/views/java/quartz.html" class="sidebar-link">Quartz定时任务</a></li><li><a href="/views/java/rabbitmq001.html" class="sidebar-link">RabbitMQ基础</a></li><li><a href="/views/java/rabbitmq002.html" class="sidebar-link">RabbitMQ进阶</a></li><li><a href="/views/java/redis01.html" class="sidebar-link">Redis基础</a></li><li><a href="/views/java/redis02.html" aria-current="page" class="active sidebar-link">Redis终结</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/views/java/redis02.html#redis基础" class="sidebar-link">Redis基础</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/views/java/redis02.html#使用场景" class="sidebar-link">使用场景</a></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#优缺点" class="sidebar-link">优缺点</a></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#基本数据结构" class="sidebar-link">基本数据结构</a></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#持久化" class="sidebar-link">持久化</a></li></ul></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#缓存击穿、雪崩、穿透" class="sidebar-link">缓存击穿、雪崩、穿透</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/views/java/redis02.html#雪崩" class="sidebar-link">雪崩</a></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#击穿" class="sidebar-link">击穿</a></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#穿透" class="sidebar-link">穿透</a></li></ul></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#redis集群" class="sidebar-link">redis集群</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/views/java/redis02.html#哨兵" class="sidebar-link">哨兵</a></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#主从同步" class="sidebar-link">主从同步</a></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#redis主从、集群、哨兵搭建" class="sidebar-link">redis主从、集群、哨兵搭建</a></li></ul></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#分布式锁-并发竞争、读写一致性" class="sidebar-link">分布式锁（并发竞争、读写一致性）</a></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#内存淘汰机制" class="sidebar-link">内存淘汰机制</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/views/java/redis02.html#redis过期策略" class="sidebar-link">redis过期策略</a></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#定期没删-我也没查询-惰性没删-那可咋整" class="sidebar-link">定期没删，我也没查询（惰性没删），那可咋整？</a></li></ul></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#redis解决" class="sidebar-link">redis解决</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/views/java/redis02.html#事前" class="sidebar-link">事前</a></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#事中" class="sidebar-link">事中</a></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#事后" class="sidebar-link">事后</a></li></ul></li><li class="sidebar-sub-header"><a href="/views/java/redis02.html#案例" class="sidebar-link">案例</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/views/java/redis02.html#秒杀" class="sidebar-link">秒杀</a></li></ul></li></ul></li><li><a href="/views/java/SSH.html" class="sidebar-link">SSH架构知识点概览</a></li><li><a href="/views/java/jwt.html" class="sidebar-link">JWT登陆认证</a></li><li><a href="/views/java/swagger2.html" class="sidebar-link">Swagger2的基本了解和使用</a></li><li><a href="/views/java/thread.html" class="sidebar-link">多线程和线程池基础</a></li><li><a href="/views/java/ThreadPool.html" class="sidebar-link">线程池进阶详解</a></li><li><a href="/views/java/ThreadLocal.html" class="sidebar-link">ThreadLocal简介</a></li><li><a href="/views/java/annotationLog.html" class="sidebar-link">注解+AOP实现日志记录</a></li><li><a href="/views/java/jvm.html" class="sidebar-link">jvm和GC</a></li><li><a href="/views/java/JUC.html" class="sidebar-link">JUC小结</a></li><li><a href="/views/java/javaLock.html" class="sidebar-link">Java中的各种锁</a></li><li><a href="/views/java/mysql_explain.html" class="sidebar-link">MySQL慢查询优化</a></li><li><a href="/views/java/ReentrantLock.html" class="sidebar-link">ReentrantLock 详解</a></li></ul></section></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-73c95a87 data-v-0b87bb44><h3 class="title" style="display:none;" data-v-73c95a87 data-v-73c95a87>Redis终结</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-73c95a87 data-v-73c95a87><input type="password" value="" data-v-73c95a87> <span data-v-73c95a87>Konck! Knock!</span> <button data-v-73c95a87>OK</button></label> <div class="footer" style="display:none;" data-v-73c95a87 data-v-73c95a87><span data-v-73c95a87><i class="iconfont reco-theme" data-v-73c95a87></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-73c95a87>vuePress-theme-reco</a></span> <span data-v-73c95a87><i class="iconfont reco-copyright" data-v-73c95a87></i> <a data-v-73c95a87><span data-v-73c95a87>flybird</span>
            
          <span data-v-73c95a87>2020 - </span>
          2021
        </a></span></div></div> <div data-v-0b87bb44><main class="page"><!----> <div class="page-title" style="display:none;"><h1>Redis终结</h1> <hr> <div data-v-7b2e794a><i class="iconfont reco-account" data-v-7b2e794a><span data-v-7b2e794a>flybird</span></i> <i class="iconfont reco-date" data-v-7b2e794a><span data-v-7b2e794a>2019-10-10</span></i> <i class="iconfont reco-eye" data-v-7b2e794a><span id="/views/java/redis02.html" data-flag-title="Your Article Title" class="leancloud-visitors" data-v-7b2e794a><a class="leancloud-visitors-count" style="font-size:.9rem;font-weight:normal;color:#999;"></a></span></i> <i class="iconfont reco-tag tags" data-v-7b2e794a><span class="tag-item" data-v-7b2e794a>
      Redis
    </span></i></div></div> <div class="theme-reco-content content__default" style="display:none;"><div id="boxx" data-v-f4ca0dac><div data-v-f4ca0dac><p v-if="true" class="custom-block-title" data-v-f4ca0dac></p> <p v-if="true" data-v-f4ca0dac></p></div></div> <p>个人看完傲丙的redis系列最后做的总结，不得不说他redis系列写的确实不错。</p> <p></p><div class="table-of-contents"><ul><li><a href="#redis基础">Redis基础</a><ul><li><a href="#使用场景">使用场景</a></li><li><a href="#优缺点">优缺点</a></li><li><a href="#基本数据结构">基本数据结构</a></li><li><a href="#持久化">持久化</a></li></ul></li><li><a href="#缓存击穿、雪崩、穿透">缓存击穿、雪崩、穿透</a><ul><li><a href="#雪崩">雪崩</a></li><li><a href="#击穿">击穿</a></li><li><a href="#穿透">穿透</a></li></ul></li><li><a href="#redis集群">redis集群</a><ul><li><a href="#哨兵">哨兵</a></li><li><a href="#主从同步">主从同步</a></li><li><a href="#redis主从、集群、哨兵搭建">redis主从、集群、哨兵搭建</a></li></ul></li><li><a href="#分布式锁-并发竞争、读写一致性">分布式锁（并发竞争、读写一致性）</a></li><li><a href="#内存淘汰机制">内存淘汰机制</a><ul><li><a href="#redis过期策略">redis过期策略</a></li><li><a href="#定期没删-我也没查询-惰性没删-那可咋整">定期没删，我也没查询（惰性没删），那可咋整？</a></li></ul></li><li><a href="#redis解决">redis解决</a><ul><li><a href="#事前">事前</a></li><li><a href="#事中">事中</a></li><li><a href="#事后">事后</a></li></ul></li><li><a href="#案例">案例</a><ul><li><a href="#秒杀">秒杀</a></li></ul></li></ul></div><p></p> <h2 id="redis基础"><a href="#redis基础" class="header-anchor">#</a> Redis基础</h2> <p>看我之前的这篇 - <a href="/views/java/redis01.html">传送门</a></p> <h3 id="使用场景"><a href="#使用场景" class="header-anchor">#</a> 使用场景</h3> <ul><li>缓存 替数据库分担压力
微博那种不断下拉分页，点赞
单点登陆
分布式锁</li></ul> <h3 id="优缺点"><a href="#优缺点" class="header-anchor">#</a> 优缺点</h3> <ol><li>基于内存的单线程非关系型数据库，由于在内存中完成操作，所以速度非常快，每秒十万+</li> <li>支持持久化</li> <li>高可用</li></ol> <h3 id="基本数据结构"><a href="#基本数据结构" class="header-anchor">#</a> 基本数据结构</h3> <ul><li><p>String</p> <ul><li>缓存功能：String字符串是最常用的数据类型，不仅仅是Redis，各个语言都是最基本类型，因此，利用Redis作为缓存，配合其它数据库作为存储层，利用Redis支持高并发的特点，可以大大加快系统的读写速度、以及降低后端数据库的压力。</li> <li>计数器：许多系统都会使用Redis作为系统的实时计数器，可以快速实现计数和查询的功能。而且最终的数据结果可以按照特定的时间落地到数据库或者其它存储介质当中进行永久保存</li> <li>共享用户Session：用户重新刷新一次界面，可能需要访问一下数据进行重新登录，或者访问页面缓存Cookie，但是可以利用Redis将用户的Session集中管理，在这种模式只需要保证Redis的高可用，每次用户Session的更新和获取都可以快速完成。大大提高效率。</li></ul></li> <li><p>Hash</p> <ul><li>这个是类似 Map 的一种结构，这个一般就是可以将结构化的数据，比如一个对象（前提是这个对象没嵌套其他的对象）给缓存在 Redis 里，然后每次读写缓存的时候，可以就操作 Hash 里的某个字段。（用的少）</li></ul></li> <li><p>List</p> <ul><li><p>比如可以通过 List 存储一些列表型的数据结构，类似粉丝列表、文章的评论列表之类的东西。</p> <ul><li>lpush key v1 v2 v3	在key中依次插入3个值,每次插入都放在最左边</li> <li>lrange key start(起始下标) stop(结束下标)	取出key中从下标start到stop(包含)的值</li> <li>lrange list (当前页-1)rows pagerows-1	分页</li></ul></li></ul></li> <li><p>Set</p> <ul><li>基于 Set 玩儿交集、并集、差集的操作，比如交集吧，我们可以把两个人的好友列表整一个交集，看看俩人的共同好友是谁？对吧。</li></ul></li> <li><p>SortedSet</p> <ul><li><p>去重且排序</p> <ul><li>排行榜：有序集合经典使用场景。例如视频网站需要对用户上传的视频做排行榜，榜单维护可能是多方面：按照时间、按照播放量、按照获得的赞数等。</li> <li>用Sorted Sets来做带权重的队列，比如普通消息的score为1，重要消息的score为2，然后工作线程可以选择按score的倒序来获取工作任务。让重要的任务优先执行。</li></ul></li></ul></li></ul> <h3 id="持久化"><a href="#持久化" class="header-anchor">#</a> 持久化</h3> <ul><li><p><strong>RDB做镜像全量持久化，AOF做增量持久化。</strong> 因为RDB会耗费较长时间，不够实时，在停机的时候会导致大量丢失数据，所以需要AOF来配合使用。在redis实例重启时，会使用RDB持久化文件重新构建内存，再使用AOF重放近期的操作指令来实现完整恢复重启之前的状态。</p> <ul><li><p>RDB</p> <ul><li>fork和cow：fork是指redis通过创建子进程来进行RDB操作，采用二进制压缩存储。cow指的是copy on write，子进程创建后，父子进程共享数据段，父进程继续提供读写服务，写脏的页面数据会逐渐和子进程分离开来。</li> <li>因为是子进程完成的，所以效率高一点，但是生成一次RDB快照文件需要花费的时间较长。</li></ul></li> <li><p>AOF</p> <ul><li>效率稍慢，类似于我们用Java流写数据时往文件上不断追加redis操作命令，AOF的执行时间通过配置redis来实现，一般是1秒</li> <li>效率稍慢，RDB五分钟一次生成快照，但是AOF是一秒一次去通过一个后台的线程fsync操作，那最多丢这一秒的数据。</li></ul></li></ul></li> <li><p>不过Redis本身的机制是 AOF持久化开启且存在AOF文件时，优先加载AOF文件；AOF关闭或者AOF文件不存在时，加载RDB文件；加载AOF/RDB文件城后，Redis启动成功；AOF/RDB文件存在错误时，Redis启动失败并打印错误信息。</p></li></ul> <h2 id="缓存击穿、雪崩、穿透"><a href="#缓存击穿、雪崩、穿透" class="header-anchor">#</a> 缓存击穿、雪崩、穿透</h2> <h3 id="雪崩"><a href="#雪崩" class="header-anchor">#</a> 雪崩</h3> <ul><li><p>原因</p> <ul><li>如果大量的key过期时间设置的过于集中，到过期的那个时间点，缓存失效，同时又有巨大访问量，没有缓存直接到DB肯定扛不住，这不就炸了吗，这就是缓存雪崩导致的
【大面积的缓存失效，打崩了DB】</li></ul></li> <li><p>场景</p> <ul><li>目前电商首页以及热点数据经常会使用定时任务刷新缓存，可能大量的数据失效时间都十分集中，如果失效时间一样，又刚好在失效的时间点大量用户涌入，就有可能造成缓存雪崩</li></ul></li> <li><p>解决方法</p> <ul><li><ol><li>我们一般在过期时间上加一个随机值，使得过期时间分散一些（推荐）</li></ol> <ul><li>setRedis（Key，value，time + Math.random() * 10000）；</li></ul></li> <li><ol start="2"><li>如果Redis是集群部署，将热点数据均匀分布在不同的Redis库中也能避免全部失效的问题，</li></ol></li> <li><ol start="3"><li>或者设置热点数据永远不过期，有更新操作就更新缓存就好了（比如运维更新了首页商品，那你刷下缓存就完事了，不要设置过期时间），电商首页的数据也可以用这个操作，保险。</li></ol></li></ul></li></ul> <h3 id="击穿"><a href="#击穿" class="header-anchor">#</a> 击穿</h3> <ul><li><p>原因</p> <ul><li>和缓存雪崩有点像，但又不大一样，缓存雪崩是大面积缓存失效导致的，而缓存击穿就像是一个key失效，但同时又面临着巨大的访问量，直接打到DB也挂了。
【并发量大的单个缓存失效，打崩DB】</li></ul></li> <li><p>解决方法</p> <ul><li>设置热点数据永远不过期</li></ul></li></ul> <h3 id="穿透"><a href="#穿透" class="header-anchor">#</a> 穿透</h3> <ul><li><p>原因</p> <ul><li>访问缓存和DB中都没有的数据，如id是 -1或者特别大的数据 的时候，攻击者并发高点就会使DB宕机的
【绕过缓存，打崩DB】</li></ul></li> <li><p>解决方法</p> <ul><li>从网管nignx开始配置，对同一ip每秒访问次数超过一定阈值的都拉黑</li> <li>对访问参数做校验，规范key的命名，并且统一缓存查询和写入的入口。这样，在入口处，对key的规范进行检测。–这样保存恶意的key被拦截。</li> <li>不管数据库中是否有数据，都在缓存中保存对应的key，值为空就行。–这样是为了避免数据库中没有这个数据，导致的平凡穿透缓存对数据库进行访问。</li> <li>如果上面缓存的空值如果太多，也会导致内存耗尽。导致不必要的内存消耗。这样就要定期的清理空值的key。避免内存被恶意占满，导致正常的功能的使用。</li></ul></li></ul> <h2 id="redis集群"><a href="#redis集群" class="header-anchor">#</a> redis集群</h2> <p>我们用到了集群的部署方式也就是Redis cluster，并且是主从同步读写分离，类似Mysql的主从同步，Redis cluster 支撑 N 个 Redis master node，每个master node都可以挂载多个 slave node。</p> <p>主节点负责写，主从同步，从负责读</p> <p>这样整个 Redis 就可以横向扩容了。如果你要支撑更大数据量的缓存，那就横向扩容更多的 master 节点，每个 master 节点就能存放更多的数据了。</p> <h3 id="哨兵"><a href="#哨兵" class="header-anchor">#</a> 哨兵</h3> <ul><li><p>功能</p> <ul><li>集群监控：负责监控 Redis master 和 slave 进程是否正常工作。</li> <li>消息通知：如果某个 Redis 实例有故障，那么哨兵负责发送消息作为报警通知给管理员。</li> <li>故障转移：如果 master node 挂掉了，会自动转移到 slave node 上。</li> <li>配置中心：如果故障转移发生了，通知 client 客户端新的 master 地址。</li></ul></li> <li><p>原理</p> <ul><li>一般最低是一主两从三哨兵，当主节点挂了时，哨兵投票选出一个（奇数个哨兵保证能选出一个）去执行故障转移</li> <li>根据选主策略选出一个新的主节点，断开当前slave所有主从关系，启动时从从同步，升级为主节点，将剩余的从节点指向到新的主节点并通知客户端主节点已更换</li></ul></li> <li><p>选主策略</p> <ul><li>slave 的 priority 设置的越低，优先级越高；</li> <li>同等情况下，slave 复制的数据越多优先级越高；</li> <li>相同的条件下 runid 越小越容易被选中。</li></ul></li></ul> <h3 id="主从同步"><a href="#主从同步" class="header-anchor">#</a> 主从同步</h3> <ul><li><p>redis同步机制</p> <ul><li>Redis可以使用主从同步，从从同步。</li></ul></li></ul> <ol><li><p>启动一台slave 的时候，他会发送一个psync命令给master</p></li> <li><p>第一次同步时，主节点做一次bgsave，并同时将后续修改操作记录到内存buffer，待完成后将RDB文件全量同步到复制节点，复制节点接受完成后将RDB镜像加载到内存。加载完成后，再通知主节点。</p></li> <li><p>后续的buffer增量数据通过AOF日志同步即可，有点类似数据库的binlog</p> <ul><li>1.编辑 vim /etc/redis/6379.conf</li></ul> <p>slaveof 172.25.254.101 6379     #redis-master 的ip</p></li> <li><p>重启 /etc/init.d/redis_6379 restart</p></li></ol> <h3 id="redis主从、集群、哨兵搭建"><a href="#redis主从、集群、哨兵搭建" class="header-anchor">#</a> redis主从、集群、哨兵搭建</h3> <ul><li><a href="https://www.cnblogs.com/xuwc/p/8900717.html" target="_blank" rel="noopener noreferrer">传送门<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <h2 id="分布式锁-并发竞争、读写一致性"><a href="#分布式锁-并发竞争、读写一致性" class="header-anchor">#</a> 分布式锁（并发竞争、读写一致性）</h2> <ul><li><p>先拿setnx来争抢锁，抢到之后，再用expire给锁加一个过期时间防止锁忘记了释放。
set指令有非常复杂的参数，一般是同时把setnx和expire合成一条指令来用的！</p></li> <li><p>代码</p></li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token comment">/**
 * redis分布式锁
 */</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">RedisLockUtil</span> <span class="token punctuation">{</span>
 
    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> LOCK_SUCCESS <span class="token operator">=</span> <span class="token string">&quot;OK&quot;</span><span class="token punctuation">;</span>
    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> SET_IF_NOT_EXIST <span class="token operator">=</span> <span class="token string">&quot;NX&quot;</span><span class="token punctuation">;</span>
    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> SET_WITH_EXPIRE_TIME <span class="token operator">=</span> <span class="token string">&quot;PX&quot;</span><span class="token punctuation">;</span>
 
    <span class="token comment">/**
     * 尝试获取分布式锁
     * @param jedis Redis客户端
     * @param lockKey 锁
     * @param requestId 请求标识
     * @param expireTime 超期时间
     * @return 是否获取成功
       @description 
        我们加锁就一行代码：jedis.set(String key, String value, String nxxx, String expx, int time)，这个set()方法一共有五个形参：
            第一个为key，我们使用key来当锁，因为key是唯一的。
            第二个为value，我们传的是requestId，很多童鞋可能不明白，有key作为锁不就够了吗，为什么还要用到value？原因就是我们在上面讲到可靠性时，分布式锁要满足第四个条件解铃还须系铃人，通过给value赋值为requestId，我们就知道这把锁是哪个请求加的了，在解锁的时候就可以有依据。requestId可以使用UUID.randomUUID().toString()方法生成。
            第三个为nxxx，这个参数我们填的是NX，意思是SET IF NOT EXIST，即当key不存在时，我们进行set操作；若key已经存在，则不做任何操作；
            第四个为expx，这个参数我们传的是PX，意思是我们要给这个key加一个过期的设置，具体时间由第五个参数决定。
            第五个为time，与第四个参数相呼应，代表key的过期时间。
        总的来说，执行set()方法就只会导致两种结果：1. 当前没有锁（key不存在），那么就进行加锁操作，并对锁设置个有效期，同时value表示加锁的客户端。2. 已有锁存在，不做任何操作。
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">boolean</span> <span class="token function">tryGetDistributedLock</span><span class="token punctuation">(</span><span class="token class-name">Jedis</span> jedis<span class="token punctuation">,</span> <span class="token class-name">String</span> lockKey<span class="token punctuation">,</span> <span class="token class-name">String</span> requestId<span class="token punctuation">,</span> <span class="token keyword">int</span> expireTime<span class="token punctuation">)</span> <span class="token punctuation">{</span>
 
        <span class="token class-name">String</span> result <span class="token operator">=</span> jedis<span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span>lockKey<span class="token punctuation">,</span> requestId<span class="token punctuation">,</span> SET_IF_NOT_EXIST<span class="token punctuation">,</span> SET_WITH_EXPIRE_TIME<span class="token punctuation">,</span> expireTime<span class="token punctuation">)</span><span class="token punctuation">;</span>
 
        <span class="token keyword">if</span> <span class="token punctuation">(</span>LOCK_SUCCESS<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
 
    <span class="token punctuation">}</span>



    <span class="token comment">/**
     * 释放分布式锁
     * @param jedis Redis客户端
     * @param lockKey 锁
     * @param requestId 请求标识
     * @return 是否释放成功
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">Long</span> RELEASE_SUCCESS <span class="token operator">=</span> <span class="token number">1L</span><span class="token punctuation">;</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">boolean</span> <span class="token function">releaseDistributedLock</span><span class="token punctuation">(</span><span class="token class-name">Jedis</span> jedis<span class="token punctuation">,</span> <span class="token class-name">String</span> lockKey<span class="token punctuation">,</span> <span class="token class-name">String</span> requestId<span class="token punctuation">)</span> <span class="token punctuation">{</span>
 
        <span class="token class-name">String</span> script <span class="token operator">=</span> <span class="token string">&quot;if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">Object</span> result <span class="token operator">=</span> jedis<span class="token punctuation">.</span><span class="token function">eval</span><span class="token punctuation">(</span>script<span class="token punctuation">,</span> <span class="token class-name">Collections</span><span class="token punctuation">.</span><span class="token function">singletonList</span><span class="token punctuation">(</span>lockKey<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token class-name">Collections</span><span class="token punctuation">.</span><span class="token function">singletonList</span><span class="token punctuation">(</span>requestId<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
 
        <span class="token keyword">if</span> <span class="token punctuation">(</span>RELEASE_SUCCESS<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
 
    <span class="token punctuation">}</span>

 
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br></div></div><h2 id="内存淘汰机制"><a href="#内存淘汰机制" class="header-anchor">#</a> 内存淘汰机制</h2> <h3 id="redis过期策略"><a href="#redis过期策略" class="header-anchor">#</a> redis过期策略</h3> <ul><li><p>定期删除</p> <ul><li><p>定期好理解，默认100s就随机抽一些设置了过期时间的key，去检查是否过期，过期了就删了。</p> <ul><li><p>为啥不扫描全部设置了过期时间的key呢？</p> <p>假如Redis里面所有的key都有过期时间，都扫描一遍？那太恐怖了，而且我们线上基本上也都是会设置一定的过期时间的。全扫描跟你去查数据库不带where条件不走索引全表扫描一样，100s一次，Redis累都累死了。</p></li></ul></li></ul></li> <li><p>惰性删除</p> <ul><li>定期删除肯定删不干净。
惰性删除，见名知意，惰性嘛，我不主动删，我懒，我等你来查询了我看看你过期没，过期就删了还不给你返回，没过期该怎么样就怎么样。</li></ul></li></ul> <h3 id="定期没删-我也没查询-惰性没删-那可咋整"><a href="#定期没删-我也没查询-惰性没删-那可咋整" class="header-anchor">#</a> 定期没删，我也没查询（惰性没删），那可咋整？</h3> <p>内存淘汰机制</p> <ul><li>allkeys-lru: 尝试回收最少使用的键（LRU），使得新添加的数据有空间存放。</li> <li>volatile-lru: 尝试回收最少使用的键（LRU），但仅限于在过期集合的键,使得新添加的数据有空间存放。</li> <li>allkeys-random: 回收随机的键使得新添加的数据有空间存放。</li> <li>volatile-random: 回收随机的键使得新添加的数据有空间存放，但仅限于在过期集合的键。</li></ul> <h2 id="redis解决"><a href="#redis解决" class="header-anchor">#</a> redis解决</h2> <h3 id="事前"><a href="#事前" class="header-anchor">#</a> 事前</h3> <ul><li>redis高可用，主从+哨兵，redis cluster，避免全盘崩溃</li></ul> <h3 id="事中"><a href="#事中" class="header-anchor">#</a> 事中</h3> <ul><li>Hystrix限流+降级，避免数据库炸裂</li></ul> <h3 id="事后"><a href="#事后" class="header-anchor">#</a> 事后</h3> <ul><li>redis持久化，一旦重启自动恢复数据</li></ul> <h2 id="案例"><a href="#案例" class="header-anchor">#</a> 案例</h2> <h3 id="秒杀"><a href="#秒杀" class="header-anchor">#</a> 秒杀</h3> <p><a href="https://mp.weixin.qq.com/s?__biz=MzAwNDA2OTM1Ng==&amp;mid=305657212&amp;idx=3&amp;sn=f6a1a6f39257b8749488d475d130f5be&amp;chksm=0cf2d7ff3b855ee9c87e266cd193ef875eaf7ec8b6a9a39699bfe5b29adb729e50919d63b631&amp;scene=18&amp;xtrack=1&amp;key=ebe57afce2f3a109e9797ed19e614ae0a4fae7ab92283105f2dab753cbe327ca1a41e1fd13a80058781edf1d44aae8b555259116a54400ac75761af7ca98f0315133e7f7b81d482d6ac49774f6eeb0e1&amp;ascene=1&amp;uin=MjA2MzU5OTU2Mw%3D%3D&amp;devicetype=Windows+10&amp;version=62070155&amp;lang=zh_CN&amp;pass_ticket=yMrUA%2FpkdEoj2uvU95vik7jUhd7bqgtcnVWYXE9vArgiCxFDX9Gwpt60%2FG1W3Epb" target="_blank" rel="noopener noreferrer">查看<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><img src="/znote/img/redis/redis02.png" alt=""></p></div> <footer class="page-edit" style="display:none;"><div class="edit-link"><a href="https://github.com/f1ybird/edit/master/docs/views/java/redis02.md" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页！</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">2020-06-21 23:07:31</span></div></footer> <!----> <!----></main> <!----> <div class="comments-wrapper" style="display:none;" data-v-0b87bb44><div class="valine-wrapper"><div id="valine"></div></div></div></div></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-44bd5a18 data-v-44bd5a18><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-44bd5a18><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-44bd5a18></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-44bd5a18></path></svg></div><!----><div data-v-48108b4c><div class="DetailsOpenFlag" style="right:1rem;bottom:9rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;font-size:14px;font-weight:500;display:none;" data-v-48108b4c>
 展开 

</div></div></div></div>
    <script src="/assets/js/app.55c4f7c3.js" defer></script><script src="/assets/js/5.86109dd2.js" defer></script><script src="/assets/js/1.74974061.js" defer></script><script src="/assets/js/2.ab8aa845.js" defer></script><script src="/assets/js/85.55a516f8.js" defer></script><script src="/assets/js/18.cfe435f1.js" defer></script>
  </body>
</html>
